"""arr_b=[]
for i in range(7):
    arr_b.append(int(input("号码:")))
a=int(input("?"))
print(arr_b[a])

import random
a_a=[]
for i in range(7):
    a_a.append(random.randint(1,10))
print(a_a[0],a_a[1],a_a[2],a_a[3],a_a[4],a_a[5],a_a[6])
print(a_a[6],a_a[5],a_a[4],a_a[3],a_a[2],a_a[1],a_a[0])

import random
a=random.randint(1,4)
if a==1:
    b=100
if a==2:
    b=101
if a==3:
    b=110
if a==4:
    b=111
print(b)
if b==100:
    c=1
if b==101:
    c=2
if b==110:
    c=3
if b==111:
    c=4
print(c)
    for event in pygame.event.get():
        if event.key == pygame.K_UP:
            a+=1
        elif event.key == pygame.K_DOWN:
            a-=1
        elif event.key == pygame.K_LEFT:
            b+=1
        elif event.key == pygame.K_RIGHT:
            b-=1
    print(a,b)



import random
import pygame
a_a=[]
a=1
b=1
for i in range(4):
    a_a.append(random.randint(1,10))
running=True
while running:
    print(a_a[0],a_a[1])
    print(a_a[2],a_a[3])"""



a_1=0
a_2=0
a_3=0
a_4=0
a_5=0
a_6=0
a_7=0
a_8=0
a_9=0
a=1
b=1
T=True
while T:
    if a==1 and b==1:
        a_1+=1
    if a==2 and b==1:
        a_2+=1
    if a==3 and b==1:
        a_3+=1
    if a==1 and b==2:
        a_4+=1
    if a==2 and b==2:
        a_5+=1
    if a==3 and b==2:
        a_6+=1
    if a==1 and b==3:
        a_7+=1
    if a==2 and b==3:
        a_8+=1
    if a==3 and b==3:
        a_9+=1
    print(a_1,a_2,a_3)
    print(a_4,a_5,a_6)
    print(a_7,a_8,a_9)
    z=input()
    if z=='a':
        a-=1
    if z=='d':
        a+=1
    if z=='s':
        b+=1
    if z=='w':
        b-=1
    if z==' ':
        a=a
        b=b
    if a>3 or a<1 or b>3 or b<1:
        if a>3:
            a-=3
        if a<1:
            a+=3
        if b>3:
            b-=3
        if b<1:
            b+=3